// @APIVersion 1.0.0
// @Title 罗老师某某项目：12345678
// @Description  给某某公司开发的什么
package routers

import (
	"chuanyouFive/controllers"

	beego "github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/filter/cors"
)

// 当我一个包里  有一些重要的事情只做一次， 那么我就写在init里

func init() {
	ns := beego.NewNamespace("/v3",

		beego.NSNamespace("/classmates",
			beego.NSInclude(
				&controllers.ClassmatesController{},
			),
		),

		beego.NSNamespace("/logs",
			beego.NSInclude(
				&controllers.LogsController{},
			),
		),

		beego.NSNamespace("/records",
			beego.NSInclude(
				&controllers.RecordsController{},
			),
		),
		// beego.NSNamespace("/teacher",
		// 	beego.NSInclude(
		// 		&controllers.TeacherController{},
		// 	),
		// ),
	)
	beego.AddNamespace(ns)
	// 允许跨域
	beego.InsertFilter("/*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins:  true,
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "token"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: false,
	}))
	//  过滤器  在调用任何接口之前，都会先 进行令牌验证
	// 4. 后端在接到前端的请求的时候，首先验证 令牌的合法性。
	// beego.InsertFilter(`/*`, beego.BeforeRouter, controllers.FilterUser)

}

// 1.复制 controller   并添加函数
// 2.在路由router里添加这个模块
